package com.devin.dao;

import com.devin.pojo.Member;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

public interface MemberMapper {

    @Insert(" insert into member values(null,#{name,javaType=String,jdbcType=VARCHAR},#{nickName,javaType=String,jdbcType=VARCHAR},#{phoneNum,javaType=String,jdbcType=VARCHAR},#{email,javaType=String,jdbcType=VARCHAR})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void addMember(Member member);

    @Select(" select * from member where id=#{memberId}")
    @Results({@Result(id = true,property = "id",column = "id",jdbcType = JdbcType.INTEGER),
            @Result(property = "name",column = "name",jdbcType = JdbcType.VARCHAR),
            @Result(property = "nickName",column = "nickName",jdbcType = JdbcType.VARCHAR),
            @Result(property = "phoneNum",column = "phoneNum",jdbcType = JdbcType.VARCHAR),
            @Result(property = "email",column = "email",jdbcType = JdbcType.VARCHAR)

    })
    Member getMemberById(int memberId);

    @Update(" delete from member where id=#{memberId}")
    void delMember(int memberId);
}

